/**
 * ZHU framework. Copyright 2012-, all rights reserved.
 *
 * $Id: InitialServiceImpl.java 47 2012-09-20 06:31:35Z zhuxiaopeng $
 * $Revision: 47 $
 * $Date: 2012-09-20 14:31:35 +0800 (四, 2012-09-20) $
 * $Author: zhuxiaopeng $
 */
package daily.service;

import java.util.*;

import javax.ejb.*;

import zhu.framework.service.*;
import daily.entity.*;

/**
 * <p>
 * </p>
 * 
 * @author $Author: zhuxiaopeng $
 * @version $Revision: 47 $ - $Date: 2012-09-20 14:31:35 +0800 (四, 2012-09-20) $
 */
@Stateless
public class InitialServiceImpl extends AbstractPersistenceOperationService {

	public Staff getStaff(final String userName, final String password) {
		final StaffLifecycle lifecycle = getLifecycleFactory().getLifecycle(StaffLifecycle.class);
		return lifecycle.findByUserNameAndPassword(userName, password);
	}

	public List<Menu> getMenuList(final Staff loginStaff) {
		final MenuLifecycle lifecycle = getLifecycleFactory().getLifecycle(MenuLifecycle.class);
		if (loginStaff.getStaffGroup() == StaffType.ADMIN) {
			return lifecycle.findAllUsed();
		}
		return lifecycle.findByStaffGroup(loginStaff.getStaffGroup());
	}

	public List<Staff> getStaffList() {
		final StaffLifecycle lifecycle = getLifecycleFactory().getLifecycle(StaffLifecycle.class);
		return lifecycle.findAllUsed();
	}
}
